﻿/*
 * 1.找到System.Windows.Forms.dll，并放在project中的Plugins文件夹下。 “D:\Unity3D\Editor\Data\Mono\lib\mono\2.0\System.Windows.Forms.dll”
 * 2.打开Player Settings 把.NET 2.0 Subset 改为.NET 2.0;
 * 3.选择的图片路径中不能存在中文
 * **/

using UnityEngine;
using System.Collections;
using System.Windows.Forms;

public class WindowFileHelper
{
    public static string FolderBrowser()
    {
        FolderBrowserDialog dialog = new FolderBrowserDialog();
        dialog.Description = "请选择文件路径";
        if (dialog.ShowDialog() == DialogResult.OK) {
            string foldPath = dialog.SelectedPath;
            return foldPath;
        }
        return "";
    }

    public static string[] FileBrower()
    {
        OpenFileDialog fileDialog = new OpenFileDialog();
        fileDialog.Multiselect = true;
        fileDialog.Title = "请选择文件";
        fileDialog.Filter = "所有文件(*.*)|*.*";
        if (fileDialog.ShowDialog() == DialogResult.OK) {
            //for (int i = 0; i < fileDialog.FileNames.Length; i++) {
            //    fileDialog.FileNames[i];
            //}
            return fileDialog.FileNames;
        }
        return null;
    }

    public static string GetSavePath()
    {
        SaveFileDialog sfd = new SaveFileDialog();
        //sfd.InitialDirectory = "E:\\";
        //sfd.Filter = "jpg文件(*.jpg)|*.jpg|png文件(*.png)|*.png";
        sfd.Filter = "所有文件(*.*)|*.*";
        if (sfd.ShowDialog() == DialogResult.OK) {
            return sfd.FileName;
        }
        return "";
    }
}
